<div class="problemindexholder" problemindex="A">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     A. Mister B and Boring Game
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     2 seconds
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
    </p>
    <p>
     All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
    </p>
    <p>
     Initially the players have a string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     consisting of the first
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     English letters in alphabetical order (for example, if
     <span class="tex-span">
      <i>
       a
      </i>
      = 5
     </span>
     , then
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     equals to "
     <span class="tex-font-style-tt">
      abcde
     </span>
     ").
    </p>
    <p>
     The players take turns appending letters to string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     . Mister B moves first.
    </p>
    <p>
     Mister B must append exactly
     <span class="tex-span">
      <i>
       b
      </i>
     </span>
     letters on each his move. He can arbitrary choose these letters. His opponent adds exactly
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     letters on each move.
    </p>
    <p>
     Mister B quickly understood that his opponent was just a computer that used a simple algorithm. The computer on each turn considers the suffix of string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     of length
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     and generates a string
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     of length
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     such that all letters in the string
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     are distinct and don't appear in the considered suffix. From multiple variants of
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     lexicographically minimal is chosen (if
     <span class="tex-span">
      <i>
       a
      </i>
      = 4
     </span>
     and the suffix is "
     <span class="tex-font-style-tt">
      bfdd
     </span>
     ", the computer chooses string
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     equal to "
     <span class="tex-font-style-tt">
      aceg
     </span>
     "). After that the chosen string
     <span class="tex-span">
      <i>
       t
      </i>
     </span>
     is appended to the end of
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     .
    </p>
    <p>
     Mister B soon found the game boring and came up with the following question: what can be the minimum possible number of different letters in string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     on the segment between positions
     <span class="tex-span">
      <i>
       l
      </i>
     </span>
     and
     <span class="tex-span">
      <i>
       r
      </i>
     </span>
     , inclusive. Letters of string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     are numerated starting from
     <span class="tex-span">
      1
     </span>
     .
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     First and only line contains four space-separated integers:
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     ,
     <span class="tex-span">
      <i>
       b
      </i>
     </span>
     ,
     <span class="tex-span">
      <i>
       l
      </i>
     </span>
     and
     <span class="tex-span">
      <i>
       r
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       a
      </i>
      ,
      <i>
       b
      </i>
      ≤ 12
     </span>
     ,
     <span class="tex-span">
      1 ≤
      <i>
       l
      </i>
      ≤
      <i>
       r
      </i>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ) — the numbers of letters each player appends and the bounds of the segment.
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print one integer — the minimum possible number of different letters in the segment from position
     <span class="tex-span">
      <i>
       l
      </i>
     </span>
     to position
     <span class="tex-span">
      <i>
       r
      </i>
     </span>
     , inclusive, in string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     .
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>1 1 1 8<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>2</pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>4 2 2 6<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>3</pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>3 7 4 6<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>1</pre>
     </div>
    </div>
   </div>
   <div class="note">
    <div class="section-title">
     Note
    </div>
    <p>
     In the first sample test one of optimal strategies generate string
     <span class="tex-span">
      <i>
       s
      </i>
      =
     </span>
     "
     <span class="tex-font-style-tt">
      abababab...
     </span>
     ", that's why answer is
     <span class="tex-span">
      2
     </span>
     .
    </p>
    <p>
     In the second sample test string
     <span class="tex-span">
      <i>
       s
      </i>
      =
     </span>
     "
     <span class="tex-font-style-tt">
      abcdbcaefg...
     </span>
     " can be obtained, chosen segment will look like "
     <span class="tex-font-style-tt">
      bcdbc
     </span>
     ", that's why answer is
     <span class="tex-span">
      3
     </span>
     .
    </p>
    <p>
     In the third sample test string
     <span class="tex-span">
      <i>
       s
      </i>
      =
     </span>
     "
     <span class="tex-font-style-tt">
      abczzzacad...
     </span>
     " can be obtained, chosen, segment will look like "
     <span class="tex-font-style-tt">
      zzz
     </span>
     ", that's why answer is
     <span class="tex-span">
      1
     </span>
     .
    </p>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
